import { Texture, TextureLoader } from 'three'

export default function useTexture(url: string): Promise<Texture> {
  const loader = new TextureLoader()

  return new Promise((resovle, reject) => {
    loader.load(
      url,
      function (texture) {
        resovle(texture)
      },
      function (err) {
        reject(err)
      }
    )
  })
}
